#!/bin/sh

PHP_DIR="/usr/syno/etc"

case $1 in
	allow)
		echo "Allowing php execution in $2" 
		sed `echo "s/^open_basedir.*/\0:$(echo "$2" | sed 's/\//\\\\\//g')/g"` $PHP_DIR/php.ini > $PHP_DIR/php.tmp && mv -f $PHP_DIR/php.tmp $PHP_DIR/php.ini
	;;
	prevent)
		echo "Preventing php execution in $2"
		sed `echo "s/:*$(echo "$2" | sed 's/\//\\\\\//g')//g"` $PHP_DIR/php.ini > $PHP_DIR/php.tmp && mv -f $PHP_DIR/php.tmp $PHP_DIR/php.ini
	;;

esac
